#ifndef V2_NIM_USER_SERVICE_H
#define V2_NIM_USER_SERVICE_H
#include "v2_nim_internal.hpp"
namespace v2 {
/// @brief 用户资料服务
/// @pre
/// 调用 `V2NIMClient::get()` 拿到 client 实例
/// 调用 `client.getUserService()` 拿到 userService 实例
/// @par 示例代码
/// @code
/// auto& client = V2NIMClient::get();
/// auto& userService = client.getUserService();
/// @endcode
class V2NIMUserService {
public:
    /// @brief 根据用户账号列表获取用户资料
    /// @param accountIds 用户账号列表
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// nstd::vector<nstd::string> accountIds = {"test1", "test2"};
    /// userService.getUserList(
    ///     accountIds,
    ///     [](nstd::vector<V2NIMUser> users) {
    ///         for (auto&& user : users) {
    ///             // do something
    ///         }
    ///     },
    ///     [](V2NIMError error) {
    ///         // get user list failed, handle error
    ///     });
    /// @endcode
    virtual void getUserList(nstd::vector<nstd::string> accountIds,
        V2NIMSuccessCallback<nstd::vector<V2NIMUser>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 更新自己的用户资料
    /// @param updateParams 更新参数
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMUserUpdateParams updateParams;
    /// updateParams.name = "name";
    /// userService.updateSelfUserProfile(
    ///     updateParams,
    ///     []() {
    ///         // update success
    ///     },
    ///     [](V2NIMError error) {
    ///         // update failed, handle error
    ///     });
    /// @endcode
    virtual void updateSelfUserProfile(V2NIMUserUpdateParams updateParams, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;

    /// @brief 添加用户到黑名单中
    /// @param accountId 用户账号
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// userService.addUserToBlockList(
    ///     "account1",
    ///     []() {
    ///         // add user to blocklist success
    ///     },
    ///     [](V2NIMError error) {
    ///         // add user to blocklist failed, handle error
    ///     });
    /// @endcode
    virtual void addUserToBlockList(nstd::string accountId, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;

    /// @brief 从黑名单中移除用户
    /// @param accountId 用户账号
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// userService.removeUserFromBlockList(
    ///     "account1",
    ///     []() {
    ///         // remove user from blocklist success
    ///     },
    ///     [](V2NIMError error) {
    ///         // remove user from blocklist failed, handle error
    ///     });
    /// @endcode
    virtual void removeUserFromBlockList(nstd::string accountId, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;

    /// @brief 获取黑名单列表
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// userService.getBlockList(
    ///     [](nstd::vector<nstd::string> accountIds) {
    ///         for (auto&& accountId : accountIds) {
    ///             // do something
    ///         }
    ///     },
    ///     [](V2NIMError error) {
    ///         // get blocklist failed, handle error
    ///     });
    /// @endcode
    virtual void getBlockList(V2NIMSuccessCallback<nstd::vector<nstd::string>> success, V2NIMFailureCallback failure) = 0;

    /// @brief 根据用户账号列表从服务器获取用户资料
    /// @oaram accountIds 需要获取用户资料的账号列表
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// nstd::vector<nstd::string> accountIds = {"test1", "test2"};
    /// userService.getUserListFromCloud(
    ///     accountIds,
    ///     [](nstd::vector<V2NIMUser> usersList) {
    ///         for (auto&& user : usersList) {
    ///             // do something
    ///         }
    ///     },
    ///     [](V2NIMError error) {
    ///         // get UserListFromCloud failed, handle error
    ///     });
    /// @endcode
    virtual void getUserListFromCloud(nstd::vector<nstd::string> accountIds,
        V2NIMSuccessCallback<nstd::vector<V2NIMUser>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 根据关键字搜索用户信息
    /// @param option 搜索选项
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMUserSearchOption option;
    /// option.keyword = "test";
    /// userService.searchUserByOption(
    ///    option,
    ///    [](nstd::vector<V2NIMUser> users) {
    ///    for (auto&& user : users) {
    ///    // do something
    ///    }
    ///    },
    ///    [](V2NIMError error) {
    ///    // search user failed, handle error
    ///    });
    /// @endcode
    virtual void searchUserByOption(const V2NIMUserSearchOption& option,
        V2NIMSuccessCallback<nstd::vector<V2NIMUser>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 添加用户资料监听器
    /// @param listener 监听器
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMUserListener listener;
    /// listener.onUserProfileChanged = [](nstd::vector<V2NIMUser> users) {
    ///     // user profile changed
    /// };
    /// listener.onBlockListAdded = [](V2NIMUser user) {
    ///     // user added to blocklist
    /// };
    /// listener.onBlockListRemoved = [](nstd::string accountId) {
    ///     // user removed from blocklist
    /// };
    /// userService.addUserListener(listener);
    /// @endcode
    virtual void addUserListener(V2NIMUserListener listener) = 0;

    /// @brief 移除用户资料监听器
    /// @param listener 监听器
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMUserListener listener;
    /// // ...
    /// userService.addUserListener(listener);
    /// // ...
    /// userService.removeUserListener(listener);
    /// @endcode
    virtual void removeUserListener(V2NIMUserListener listener) = 0;
};
}  // namespace v2

#endif
